package com.tianzj.boot.mvc.controller.log;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.tianzj.boot.mvc.entity.log.SysLog;
import com.tianzj.boot.mvc.service.log.SysLogService;
import com.tianzj.boot.util.JsonUtil;
import com.tianzj.boot.util.PageVo.PageVo;

@RestController
@RequestMapping("sysLog")
public class SysLogController {
	
	@Autowired
	private SysLogService sysLogService;
	
	@GetMapping("logList")
	public ModelAndView logList(){
		return new ModelAndView("log/logList");
	}
	
	@PostMapping("getLogList")
	public String getLogList(PageVo pageVo,SysLog sysLog){
		Pageable pageable=new PageRequest(pageVo.getPageNumber()-1,pageVo.getPageSize());
		Page<SysLog> logList = sysLogService.getSysLogList(sysLog,pageable);
		return JsonUtil.list2BootStrapJson(logList);
	}
	
	@PostMapping("getLogById")
	public SysLog getLogById(SysLog sysLog){
		SysLog log =sysLogService.getLogById(sysLog.getId());
		return log;
	}
}
